home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / OldSrc / CH1 / SRC / OPCODES.FRM < prev    next >
Text File  |  1995-12-13  |  4KB  |  149 lines

  1. VERSION 4.00
  2. Begin VB.Form OpcodeForm 
  3.    Caption         =   "Opcodes"
  4.    ClientHeight    =   3960
  5.    ClientLeft      =   2085
  6.    ClientTop       =   1485
  7.    ClientWidth     =   5070
  8.    Height          =   4650
  9.    Left            =   2025
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3960
  12.    ScaleWidth      =   5070
  13.    Top             =   855
  14.    Width           =   5190
  15.    Begin VB.PictureBox Source 
  16.       AutoRedraw      =   -1  'True
  17.       AutoSize        =   -1  'True
  18.       Height          =   1020
  19.       Index           =   2
  20.       Left            =   2520
  21.       Picture         =   "OPCODES.frx":0000
  22.       ScaleHeight     =   64
  23.       ScaleMode       =   3  'Pixel
  24.       ScaleWidth      =   64
  25.       TabIndex        =   4
  26.       Top             =   2520
  27.       Width           =   1020
  28.    End
  29.    Begin VB.PictureBox Source 
  30.       AutoRedraw      =   -1  'True
  31.       AutoSize        =   -1  'True
  32.       Height          =   1020
  33.       Index           =   1
  34.       Left            =   2520
  35.       Picture         =   "OPCODES.frx":0882
  36.       ScaleHeight     =   64
  37.       ScaleMode       =   3  'Pixel
  38.       ScaleWidth      =   64
  39.       TabIndex        =   3
  40.       Top             =   1440
  41.       Width           =   1020
  42.    End
  43.    Begin VB.ListBox OpcodeList 
  44.       Height          =   3765
  45.       Left            =   120
  46.       TabIndex        =   2
  47.       Top             =   120
  48.       Width           =   2295
  49.    End
  50.    Begin VB.PictureBox Destination 
  51.       AutoRedraw      =   -1  'True
  52.       AutoSize        =   -1  'True
  53.       Height          =   1020
  54.       Left            =   3960
  55.       ScaleHeight     =   64
  56.       ScaleMode       =   3  'Pixel
  57.       ScaleWidth      =   64
  58.       TabIndex        =   1
  59.       Top             =   1440
  60.       Width           =   1020
  61.    End
  62.    Begin VB.PictureBox Source 
  63.       AutoRedraw      =   -1  'True
  64.       AutoSize        =   -1  'True
  65.       Height          =   1020
  66.       Index           =   0
  67.       Left            =   2520
  68.       Picture         =   "OPCODES.frx":1104
  69.       ScaleHeight     =   64
  70.       ScaleMode       =   3  'Pixel
  71.       ScaleWidth      =   64
  72.       TabIndex        =   0
  73.       Top             =   360
  74.       Width           =   1020
  75.    End
  76.    Begin VB.Menu mnuFile 
  77.       Caption         =   "&File"
  78.       Begin VB.Menu mnuFileExit 
  79.          Caption         =   "E&xit"
  80.       End
  81.    End
  82. End
  83. Attribute VB_Name = "OpcodeForm"
  84. Attribute VB_Creatable = False
  85. Attribute VB_Exposed = False
  86. Option Explicit
  87.  
  88. ' ***********************************************
  89. ' Add an opcode's name and value to the list of
  90. ' choices.
  91. ' ***********************************************
  92. Sub AddOpcode(name As String, value As Long)
  93.     OpcodeList.AddItem name
  94.     OpcodeList.ItemData(OpcodeList.NewIndex) = value
  95. End Sub
  96.  
  97. Private Sub Form_Load()
  98. Dim copy_index As Integer
  99.  
  100.     ' Load the opcode choices.
  101.     AddOpcode "vbBlackness", vbBlackness
  102.     AddOpcode "vbDstInvert", vbDstInvert
  103.     AddOpcode "vbMergeCopy", vbMergeCopy
  104.     AddOpcode "vbMergePaint", vbMergePaint
  105.     AddOpcode "vbNotSrcCopy", vbNotSrcCopy
  106.     AddOpcode "vbSrcErase", vbSrcErase
  107.     AddOpcode "vbPatCopy", vbPatCopy
  108.     AddOpcode "vbPatInvert", vbPatInvert
  109.     AddOpcode "vbPatPaint", vbPatPaint
  110.     AddOpcode "vbSrcAnd", vbSrcAnd
  111.     AddOpcode "vbSrcCopy", vbSrcCopy
  112.     copy_index = OpcodeList.NewIndex
  113.     AddOpcode "vbSrcErase", vbSrcErase
  114.     AddOpcode "vbSrcInvert", vbSrcInvert
  115.     AddOpcode "vbSrcPaint", vbSrcPaint
  116.     AddOpcode "vbWhiteness", vbWhiteness
  117.  
  118.     ' Start with vbSrcCopy.
  119.     OpcodeList.ListIndex = copy_index
  120. End Sub
  121.  
  122. Private Sub mnuFileExit_Click()
  123.     Unload Me
  124. End Sub
  125.  
  126. Private Sub Source_Click(Index As Integer)
  127. Dim X As Single
  128. Dim Y As Single
  129. Dim wid As Single
  130. Dim hgt As Single
  131. Dim opcode As Long
  132.  
  133.     X = Source(Index).ScaleLeft
  134.     Y = Source(Index).ScaleTop
  135.     wid = Source(Index).ScaleWidth
  136.     hgt = Source(Index).ScaleHeight
  137.     opcode = OpcodeList.ItemData(OpcodeList.ListIndex)
  138.     
  139.     With Destination
  140.         ' Add the source using the chosen opcode.
  141.         .PaintPicture Source(Index).Picture, _
  142.             .ScaleLeft, .ScaleTop, _
  143.             .ScaleWidth, .ScaleHeight, _
  144.             X, Y, wid, hgt, opcode
  145.     End With
  146. End Sub
  147.  
  148.  
  149.